home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CPP100.ZIP / CPPLMAT3.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  8.2 KB  |  223 lines

  1. /*****************************************************************************/
  2. /*       (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved         */
  3. /*****************************************************************************/
  4. /*    This source-code is NOT public domain nor Freeware, this is part of    */
  5. /*              'The C Programming Package' which is Shareware.              */
  6. /*   If you use this code, please register and get a free Full-VGA version   */
  7. /*****************************************************************************/
  8.                             /*------------------*
  9.                              *    CPPLMAT3.C    *
  10.                              *  Hardware config *
  11.                              *      Contd 2     *
  12.                              *------------------*/
  13.  
  14.  /* Included Files */
  15.  # include <stdio.h>
  16.  # include <io.h>
  17.  # include <dos.h>
  18.  # include <fcntl.h>
  19.  # include <bios.h>
  20.  # include <stdlib.h>
  21.  # include <SYS\stat.h>
  22.  # include <conio.h>
  23.  # include <alloc.h>
  24.  # include <process.h>
  25.  # include <ctype.h>
  26.  # include <string.h>
  27.  
  28.  /* Global Variables */
  29.  extern int x,y,z,i,j,k,l,m,n,bm,xm,ym,chx2,return2;
  30.  extern int colour1,colour2,colour3,colour4,colour5,chif,background,colourprov,colourchoice;
  31.  extern unsigned char c1,nc1[],trashcan[];
  32.  
  33.  /*-----------------------*
  34.   * GET COLOUR 3 KEYBOARD *
  35.   *-----------------------*/
  36.   int get_colour3_keyboard()
  37.     {
  38.       j=get_key();
  39.       /* If we typed between -1 and 4, it is OK else we search */
  40.       if(j<5)                          return(j);
  41.       /* If <Enter> the modifications are confirmed */
  42.       if(c1==13)                       return(21);
  43.       if((c1==67)||(c1==99)){
  44.         /* If we want to change the choice : C c */
  45.     chx2=1;                        return(21);
  46.       }
  47.       if((c1==79)||(c1==111)){
  48.         /* If we want to confirm the change O o */
  49.     chx2=2;                        return(21);
  50.       }
  51.       if((c1==81)||(c1==113)){
  52.         /* If we want to quit without modifying Q q */
  53.     chx2=3;                        return(21);
  54.       }
  55.       /* In the other cases we return 20 = no choice */
  56.       return(20);
  57.     }
  58.  /*-------------------*
  59.   * GET COLOUR3 MOUSE *
  60.   *-------------------*/
  61.   int get_colour3_mouse()
  62.     {
  63.       if((xm>3)&&(xm<46)&&(ym>3)&&(ym<11)){
  64.         /* the mouse is in the colours zone */
  65.         if(ym==4)                      colourprov=7;
  66.         if(ym==6)                      colourprov=112;
  67.         if(ym==8)                      colourprov=135;
  68.         if(ym==10)                     colourprov=240;
  69.       }
  70.       if(ym==18){
  71.         /* With the mouse it is choice and validation */
  72.     if((xm>3)&&(xm<13)){
  73.           /* Change the colour */
  74.       chx2=1;                      return(21);
  75.     }
  76.     if((xm>13)&&(xm<29)){
  77.           /* Confirm the modification */
  78.       chx2=2;                      return(21);
  79.     }
  80.     if((xm>29)&&(xm<45)){
  81.           /* Quit without changing */
  82.       chx2=3;                      return(21);
  83.     }
  84.       }
  85.       /* other cases : return 20 */
  86.       return(20);
  87.     }
  88.  /*-----------------------*
  89.   * DISPLAY CHOICE SCREEN *
  90.   *-----------------------*/
  91.   void display_choice_mono_screen()
  92.     {
  93.       /* Erase the zone that will be used */
  94.       hide_the_mouse();
  95.       textattr(15);                    window(2,3,59,24);
  96.       clrscr();                        window(1,1,80,25);
  97.       /* Draw the grid */
  98.       gotoxy(3,3);   cputs("┌───┬─────────────────────────────────────────┐");
  99.       gotoxy(3,4);   cputs("│ 1 │                                         │");
  100.       gotoxy(3,5);   cputs("├───┼─────────────────────────────────────────┤");
  101.       gotoxy(3,6);   cputs("│ 2 │                                         │");
  102.       gotoxy(3,7);   cputs("├───┼─────────────────────────────────────────┤");
  103.       gotoxy(3,8);   cputs("│ 3 │                                         │");
  104.       gotoxy(3,9);   cputs("├───┼─────────────────────────────────────────┤");
  105.       gotoxy(3,10);  cputs("│ 4 │                                         │");
  106.       gotoxy(3,11);  cputs("└───┴─────────────────────────────────────────┘");
  107.       gotoxy(3,17);  cputs("╔═════════╤══════════════╤════════════════════╗");
  108.       gotoxy(3,18);  cputs("║  Choose │cOnfirm choice│ Quit without modif.║");
  109.       gotoxy(3,19);  cputs("╚═════════╧══════════════╧════════════════════╝");
  110.       gotoxy(3,21);  cputs(" Current colours. Your choice ( Keyboard or mouse )     ");
  111.       /* And we fill it with a sentence in the right colour */
  112.       textattr(7);
  113.       gotoxy(8,4);            cputs(" Text with colour choice number 1 ");
  114.       textattr(112);
  115.       gotoxy(8,6);            cputs(" Text with colour choice number 2 ");
  116.       textattr(135);
  117.       gotoxy(8,8);            cputs(" Text with colour choice number 3 ");
  118.       textattr(240);
  119.       gotoxy(8,10);           cputs(" Text with colour choice number 4 ");
  120.       show_the_mouse();
  121.     }
  122.  /*-----------------------------*
  123.   * DISPLAY CHOICE MONO COLOURS *
  124.   *-----------------------------*/
  125.   void display_choice_mono_colour()
  126.     {
  127.       hide_the_mouse();               textattr(7);
  128.       gotoxy(4,18);                    cputs(" Choose ");
  129.       gotoxy(14,18);                   cputs(" cOnfirm choice");
  130.       gotoxy(29,18);                   cputs(" Quit without modif. ");
  131.       textattr(7);                     highvideo();
  132.       gotoxy(5,18);                    cputs("C");
  133.       gotoxy(16,18);                   cputs("O");
  134.       gotoxy(30,18);                   cputs("Q");
  135.       normvideo();
  136.       /* Display this line with current colours */
  137.       textattr(colourprov);
  138.       gotoxy(3,21);  cputs(" Current colours. Your choice ( Keyboard or mouse )     ");
  139.       /* Outline the choice */
  140.       textattr(135);
  141.       if(chx2==1){
  142.         gotoxy(4,18);                  cputs(" Choose ");
  143.       }
  144.       if(chx2==2){
  145.         gotoxy(14,18);                 cputs(" cOnfirm choice ");
  146.       }
  147.       if(chx2==3){
  148.         gotoxy(29,18);                 cputs(" Quit without modif. ");
  149.       }
  150.       show_the_mouse();
  151.     }
  152.  /*-----------------------*
  153.   * CHANGE MONO COLOURS *
  154.   *-----------------------*/
  155.   void change_mono_colour()
  156.     {
  157.       textattr(colourprov+128);
  158.       gotoxy(3,21);  cputs(" Enter the new background colour, please. Your choice:      ");
  159.       gotoxy(57,21);                   c1=getch();
  160.       z=get_colour2_keyboard();
  161.       if(z==1)                         colourprov=7;
  162.       if(z==2)                         colourprov=112;
  163.       if(z==3)                         colourprov=135;
  164.       if(z==4)                         colourprov=240;
  165.     }
  166.  /*----------------------*
  167.   * CHOOSE MONO COLOUR *
  168.   *----------------------*/
  169.   void choose_mono_colour()
  170.     {
  171.       /* Update the new choice */
  172.       display_colour_choice();         display_choice_mono_screen();
  173.       chx2=1;                          load_temporary_colour();
  174.       while(1){
  175.         display_choice_mono_colour();
  176.     while(1){
  177.       if(kbhit()){
  178.             /* If we pressed a key */
  179.         c1=getch();
  180.         if(c1==0){
  181.               /* The key is coded in 2 bytes. Cut the 2nd one */
  182.           c1=getch();
  183.               return2=get_special_colour2();  break;
  184.         }
  185.         else{
  186.               /* We pressed a key */
  187.               return2=get_colour3_keyboard();   break;
  188.         }
  189.           }
  190.           /* Else test the mouse */
  191.           get_mouse_state();
  192.       if(bm==1){
  193.             /* We pressed a mouse button */
  194.             return2=get_colour3_mouse();     break;
  195.       }
  196.     }
  197.         /* We treat the result */
  198.         if(return2==-1)                return;
  199.         if(return2==21){
  200.           /* We confirmed or we pressed <Enter> to confirm */
  201.       if(chx2==1){
  202.             /* We want to change the colour */
  203.             change_mono_colour();
  204.       }
  205.       if(chx2==2){
  206.             /* We return after copying the colour value */
  207.             copy_new_value_in_colour();
  208.         return;
  209.       }
  210.       if(chx2==3){
  211.             /* We return without changing the colour value */
  212.         return;
  213.       }
  214.     }
  215.         if(return2==22){
  216.           /* F1 = On-line help */
  217.           display_help("CONFIGUR",92,4,1);   restore_help_screen();
  218.     }
  219.       }
  220.     }
  221. /* End of the hardware config file */
  222.  
  223.